<?php


namespace app\admin\model;


use think\Model;

/**
 * Class HtnsActivity
 * @package app\admin\model
 * @desc 海淘女神-省市区城市表
 */
class HtnsSystemCity extends Model
{
    protected $connection = 'htns';
    protected $table = 'eb_system_city';

    // 获取省份列表
    public function getProvince()
    {
        $where[] = ['parent_id', '=', 0];
        $where[] = ['level', '=', 0];
        $res     = self::where($where)->select()->toArray();
        return $res;
    }

    // 获取市列表
    public function getCity($parentId)
    {
        $where[] = ['parent_id', '=', $parentId];
        $where[] = ['level', '=', 1];
        $res     = self::where($where)->select()->toArray();
        return $res;
    }

    // 获取区列表
    public function getArea($parentId)
    {
        $where[] = ['parent_id', '=', $parentId];
        $where[] = ['level', '=', 2];
        $res     = self::where($where)->select()->toArray();
        return $res;
    }

}